package com.yunsom.testdemo.design.remark;

/**
 * @author Xbao
 * @version 1.0
 * @description 备忘录模式
 * @date 2021/3/8 14:44
 */
public class RemarkTest {

  public static void main(String[] args) {

    Originator originator = new Originator();
    originator.setState("origin_state");
    System.out.println(originator.getState());

    CareTaker careTaker = new CareTaker();
    careTaker.setMemento(originator.setStateToMemento());

    originator.setState("new_state");
    System.out.println(originator.getState());

    originator.recovery(careTaker.getMemento());
    System.out.println(originator.getState());

  }
}
